package com.yanqu.road.server.cmd.activity.jinli;

import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.activity.JinLiProto;
import com.yanqu.road.server.cmd.CrossCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.manager.activity.jinli.CrossJinLiActivity;
import com.yanqu.road.server.manager.activity.jinli.CrossJinLiMgr;
import com.yanqu.road.server.protocol.CrossProtocol;

/**
 * 添加锦鲤
 */
@Cmd(code = CrossProtocol.C_CROSS_JINLI_SYNC_DATA, desc = "锦鲤信息同步")
public class CrossJinLiSyncDataCmd extends CrossCommand {

    private int activityId;

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        JinLiProto.CrossJinLiSyncDataMsg reqMsg = JinLiProto.CrossJinLiSyncDataMsg.parseFrom(packet.getBytes());
        activityId = reqMsg.getActivityId();
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {
        CrossJinLiActivity activity = CrossJinLiMgr.getActivity(activityId);
        if (activity == null) {
            return;
        }
        // 信息同步
        activity.syncUserJinLiData(serverId, packet.getPlayerId());
    }

    @Override
    public void sendData() {

    }
}
